package org.xdq.观察者模式3;

import java.util.Observable;

public class Goods extends Observable {

    private int price;

    public Goods(int price){
        this.price = price;
    }

    public void setPrice(int price) {
        int var = price - this.price;
        this.price = price;
        if(var == 0){
            return;
        }
        setChanged();//声明状态已改变
        this.notifyObservers(var);
    }
}
